﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace YunxSoft.Abp.LanguageManagement;

[Area(LanguageManagementRemoteServiceConsts.ModuleName)]
[RemoteService(Name = LanguageManagementRemoteServiceConsts.RemoteServiceName)]
[Route("api/LanguageManagement/Languages")]
public class LanguageController : LanguageManagementController, ILanguageAppService
{
    protected ILanguageAppService LanguageAppService;

    public LanguageController(ILanguageAppService languageAppService)
    {
        LanguageAppService = languageAppService;
    }

    [HttpGet]
    [Route("All")]
    public virtual  Task<ListResultDto<LanguageDto>> GetAllListAsync()
    {
        return LanguageAppService.GetAllListAsync();
    }
    
    
    [HttpGet]
    public virtual Task<PagedResultDto<LanguageDto>> GetListAsync(GetLanguagesInput input)
    {
        return LanguageAppService.GetListAsync(input);
    }

    [Route("{id}")]
    [HttpGet]
    public virtual async Task<LanguageDto> GetAsync(Guid id)
    {
        return await this.LanguageAppService.GetAsync(id);
    }

    [HttpPost]
    public virtual async Task<LanguageDto> CreateAsync(CreateLanguageDto input)
    {
        return await this.LanguageAppService.CreateAsync(input);
    }

    [HttpPut]
    [Route("{id}")]
    public virtual async Task<LanguageDto> UpdateAsync(Guid id, UpdateLanguageDto input)
    {
        return await this.LanguageAppService.UpdateAsync(id, input);
    }

    [HttpDelete]
    [Route("{id}")]
    public virtual async Task DeleteAsync(Guid id)
    {
        await this.LanguageAppService.DeleteAsync(id);
    }

    [Route("{id}/SetAsDefault")]
    [HttpPut]
    public virtual async Task SetAsDefaultAsync(Guid id)
    {
        await this.LanguageAppService.SetAsDefaultAsync(id);
    }

    [Route("Resources")]
    [HttpGet]
    public virtual Task<List<LanguageResourceDto>> GetResourcesAsync()
    {
        return this.LanguageAppService.GetResourcesAsync();
    }

    [HttpGet]
    [Route("CultureList")]
    public virtual Task<List<CultureInfoDto>> GetCultureListAsync()
    {
        return this.LanguageAppService.GetCultureListAsync();
    }
}
